// [[ OnflowGenerator Entity UUID: 334d724ba7d143a49549086b85b568de ]]
package com.itdct.onflow.system.task.entity

import com.baomidou.mybatisplus.annotation.TableName
import com.itdct.onflow.core.annotation.Column
import com.itdct.onflow.core.annotation.ColumnRelateDict
import com.itdct.onflow.core.annotation.TableDescription
import com.itdct.onflow.core.entity.BaseUserEntity
import java.util.*

/**
 * @author Zhouwx
 * @date 2025/8/21 19:45:10
 * @version 1.0
 * @description
 */
@TableDescription("定时任务")
@TableName("sys_task")
class SysTaskEntity : BaseUserEntity() {
    @Column(comment = "任务名", nullable = false, length = 50, sort = 10, forSelect = true)
    var name = ""

    @Column(comment = "任务执行类", nullable = false, unique = true, length = 100, sort = 20)
    var taskClass = ""

    @Column(comment = "额外参数", length = 1000, sort = 30)
    var extraArg: String? = null

    @ColumnRelateDict(dictCode = "sysTaskCycleType")
    @Column(comment = "循环类型", nullable = false, defaultValue = "0", sort = 40)
    var cycleType = 0

    @ColumnRelateDict(dictCode = "sysTaskExecuteState")
    @Column(comment = "执行状态", nullable = false, defaultValue = "0", sort = 50)
    var executeState = 0

    @Column(comment = "cron表达式", length = 64, sort = 60)
    var cron: String? = null

    @Column(comment = "指定执行时间", length = 64, sort = 70)
    var specifyTime: String? = null

    @Column(comment = "间隔时间", sort = 80)
    var intervalTime: Long? = null

    @Column(comment = "首次开始时间", sort = 90)
    var firstTime: Date? = null

    @Column(comment = "首次延迟时间", sort = 100)
    var firstDelayTime: Long? = null

    @Column(comment = "是否启用", nullable = false, defaultValue = "1", sort = 110)
    var enable = true

    @Column(comment = "上次开始时间", sort = 120)
    var lastStartTime: Date? = null

    @Column(comment = "上次结束时间", sort = 130)
    var lastEndTime: Date? = null

    @Column(comment = "执行次数", defaultValue = "0", sort = 140)
    var executeTimes = 0

    @ColumnRelateDict(dictCode = "platformType")
    @Column(comment = "平台类型", nullable = false, length = 100, defaultValue = "onflow-backend", indexed = true, sort = 150)
    var platformType = ""

    @Column(comment = "备注", length = 500, sort = 160)
    var remark: String? = null
}